﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SCZS.Example.DTOModel;
using SCZS.Example.IService;
using SCZS.Example.Model.Example;

namespace SCZS.Example.UserMicroservice.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private IUserService _userService;
        public UserController(IUserService userService)
        {
            _userService = userService;
        }

        /// <summary>
        /// 根据账号密码查询用户
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        [Route("QueryUser")]
        [HttpGet]
        public async Task<Output<SysUserInfo>> QueryUser(string userAccount,  string password)
        {
            return await _userService.QueryUser(userAccount, password);
        }

        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="user"></param>
        /// <param name="code"></param>
        [HttpPost]
        [Route("Register")]
        public async Task<Output> Register([FromBody]SysUserInfo user,  string code)
        {
            return await _userService.Register(user, code);
        }
    }
}
